package com.kaifamiao.date1105;

public class Decimal {
	
	private static final String SYMBOLS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	
	// private 私有的
	// final 最终的、不可变的
	private final long value ;

	public Decimal(long value) {
		super();
		this.value = value;
	}
	
	private String toString( int radix ) {
		String result = "" ;
		long x = this.value ;
		while( x != 0 ) {
			int y = (int)( x % radix ) ;
			char symbol = SYMBOLS.charAt( y ); // 将求得的余数当作字符串索引使用
			result = symbol + result ;
			x = x / radix ;
		}
		return result ;
	}
	
	public String toHexString() {
		return "0x" + this.toString( 16 );
	}
	
	public String toOctString() {
		return "0" + this.toString( 8 );
	}
	
	public String toBinaryString() {
		return "0b" + this.toString( 2 );
	}

}
